summaryrefslogtreecommitdiffstats
path: root/src/net/gcdc/asn1/datatypesimpl/OctetString.java
blob: e21a0989f66d825c520b436865ac1589ad02a4a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package net.gcdc.asn1.datatypesimpl;

import java.util.Collection;
import java.util.List;

import net.gcdc.asn1.datatypes.Asn1SequenceOf;

/*
 * Sequence of Asn1Integer for restricted integers
 * 
 * 
 */
public class OctetString extends Asn1SequenceOf<Byte> {
    public OctetString() { super(); }
    public OctetString(Collection<Byte> coll) { super(coll); }

	public OctetString(List<Byte> numbers) {
		super();
		this.addAll(numbers);
	}
	
	public static OctetString getSequence(List<Byte> numList) {
		if (numList == null || numList.isEmpty()) return null;
		return new OctetString(numList);
	}
	
	
	public byte[] toByteArray () {
		
		byte[] bytes= new byte[this.size()];
		
		for (int i = 0; i < this.size(); i++){
			bytes[i] = this.get(i);
		}
		
		return bytes;
	}
	
	public OctetString(byte[] bytes){
		super();
		for (int i= 0;i < bytes.length; i++){
		  this.add(bytes[i]);
		}
	}
	
}